Importing and exporting markup language data in a spreadsheet application document

ABSTRACT

Methods and systems are provided for importing markup language formatted data into a spreadsheet document and for exporting markup language formatted data from a spreadsheet document. XML data is associated with an XML schema file defining XML data types and data type definitions for applying XML data to the document. An XML data map is prepared that relates that any XML data applied to the document back to corresponding XML elements or attributes defined in the associated schema file. When the document is imported into a spreadsheet application grid, the data map is parsed to find XPATHs in the imported spreadsheet document of XML data and the user entered data. Each XPATH is executed to determine the location, data types and user data for each cell or list object in the document that is related back to the associated schema file. The cells and lists are populated with the XML data and user data, and the data is rendered in the spreadsheet according to the formatting dictated by the XML data applied to the spreadsheet in association with the XML schema file. After an imported document has been edited, or after a document is created to include the application of XML data in association with a selected XML schema file, the document may be exported such that the XML data applied to the document is maintained for subsequent import and use of the document.

CROSS-REFERENCE TO RELATED APPLICATIONS

This patent application is a divisional of U.S. patent application Ser.No. 10/377,145, entitled “IMPORTING AND EXPORTING MARKUP LANGUAGE DATAIN A SPREADSHEET DOCUMENT,” filed on Feb. 28, 2003 and assigned to thesame assignee as this application. The aforementioned patent applicationis expressly incorporated herein by reference.

FIELD OF THE INVENTION

The present invention relates generally to importing markup languagedata to and exporting markup language data from a spreadsheet document.More particularly, the present invention relates to importing aneXtensible Markup Language file into a spreadsheet document and toexporting an eXtensible Markup Language document from a spreadsheetdocument.

BACKGROUND OF THE INVENTION

Computer software applications allow users to create a variety ofdocuments for use in work, education and leisure. For example, aspreadsheet application allows users to store, manipulate, print anddisplay a variety of alphanumeric data. A word processing applicationallows users to create letters, articles, books, memoranda, and thelike. Such applications have a number of well-known strengths, includingrich editing, formatting and calculation.

To keep up with demands for more advanced functionality for suchcomputer software applications, software developers have begun to usestructured data formats, including markup languages such as eXtensibleMarkup Language (XML), to allow users to annotate a software applicationdocument to give the document a useful structure apart from the normalfunctionality of the software application responsible for creating thedocument or the visible formatting associated with the document. Forexample, the user may wish to create using her spreadsheet application atemplate document for preparation of a purchase order to be used in hercompany's sales department. By applying structure to the document,purchasers or other institutions or persons receiving the document maymake use of the structure by processing the document to utilize datadefined by the document structure.

Some software applications, such as word processing applications, allowusers to annotate a document with XML elements so that the user maydefine certain data types and data definitions for data inserted intothe document. A resume document, for example, may include an“experience” section in which the user will include present and pastwork experience. Using XML, the user may desire to markup the“experience” section of the document to define that certain allowableinformation in a prescribed order and in a prescribed number may beincluded in the “experience” section of the document. For example, theuser may wish to markup the experience section of the document to allowfour present or past experience items.

Unfortunately, prior art spreadsheet applications allow very limited useof XML data. Bulk XML data may be imported where the user points to anXML file and the spreadsheet application imports that file into thespreadsheet grid. But, the user gets no control over how the data islaid out or which data is imported because all of the data is imported.Under prior spreadsheet applications, manual coding of XML data to aspreadsheet application may be required in which a programmer writestheir own custom code for handling import and/or export of XML data.This code may be in the form of an XSLT transformation file, or it maybe a more traditional programming language like VBA or C++. Such customprogramming is time consuming, expensive and is difficult to applygenerally to spreadsheet documents.

Prior spreadsheet applications do not establish a relationship betweenthe XML data and the spreadsheet grid. A relationship between the XMLdata and the grid allows the user to have a custom view of the XML data.For example, if a user only wants elements <a>, <b>, and <e> to show upin the grid, and to skip elements <c> and <d>, that preference needs tobe stored somewhere. Furthermore, if the user wants element <b> to bedisplayed first and show up in column A, followed by elements <a> and<e> in columns B and C, that preference needs to be stored as well. Ifthe user wants the data to begin appearing in row 6 rather than at thetop of the grid sheet, that preference will need to be stored as well.Because prior spreadsheet applications allow no custom control over howthe data is imported and displayed, there is nothing for the spreadsheetapplication to remember about the data. Accordingly, no relationship,between the spreadsheet and the XML data is established.

Accordingly there is a need in the art for methods and systems thatallow users to import and/or export XML data to and from spreadsheetgrids. There is further a need for methods and systems for that allowspreadsheet documents to exchange data with other XML-enabledapplications whether or not the other applications understand theprogramming or functionality of the spreadsheet application. There isfurther a need for methods and systems that allow users to build customspreadsheet application views of XML data so that they may readily view,analyze, edit, and produce XML data. There is further a need for methodsand systems that allow programmers to write programs that interactdirectly with XML data in a spreadsheet grid using an XML context.

It is with respect to these and other considerations that the presentinvention has been made.

SUMMARY OF THE INVENTION

Embodiments of the present invention provide methods and systems forimporting markup language formatted data into a spreadsheet document andfor exporting markup language formatted data from a spreadsheetdocument. More particularly, embodiments of the present invention solvethe above and other problems by providing methods and systems forimporting eXtensible Markup Language (XML) data and associated userdata, if available, into a spreadsheet document and for exporting XMLdata and associated user data, if available, from a spreadsheetdocument.

According to one aspect of the invention, an XML document or XML data isassociated with an XML schema file defining XML data types and data typedefinitions for applying XML data to the spreadsheet document. An XMLdata map is prepared that relates a spreadsheet grid to the schema file.Generally, the map is the relationship between the grid and the XMLschema. Element <a> goes in cell B1, for instance. The map contains anXPATH that points to element <a>, and the XPATH is paired with a gridreference. The mapping is essentially a collection of pairings where foreach pairing a given XML element or attribute referenced by an XPATHcorresponds to a given location in the grid.

When the XML document is subsequently imported into a spreadsheetapplication grid, the XML map is selected for determining therelationships between XML data applied to the spreadsheet applicationdocument and the XML schema file associated with the document. The XMLdata map is parsed to find XPATHs in the imported spreadsheet documentpointing in the document to an associated schema file. Each XPATH isexecuted to determine the location, data types and user data for eachcell or list object in the document that is related back to theassociated schema file. The cells and lists are populated withassociated XML data in locations in the grid where the XML data ismapped and according to the rules (element names, syntax, etc.) of theassociated schema file. That is, the grid is populated with XML data,and the data lands in the proper cells, lists, and columns according tothe relationships between the spreadsheet grid and schema as specifiedin the XML data map.

According to another aspect of the invention, after an imported XMLdocument has been edited, the data in that document may be exported asXML data. Similarly, a mapped spreadsheet document can be used as ablank template. The user opens the spreadsheet document (template),enters data into the mapped regions, and then exports the data as XMLdata. In either case, the exported XML data may be processed by anyother XML-enabled application, for example, another desktop application,a backend database, a spreadsheet document that has been mapped to thesame schema, and the like.

Prior to exporting the edited or created document, an XML data maprelating XML data in the document to associated elements or attributesof a selected XML schema file is selected. The XML data map is iteratedto find the location of each cell or list object in the document thatcontains XML data and to locate an XPATH in each of such cell or listobject for pointing the XML data associated with the cell or list objectback to associated XML elements or attributes in the selected XML schemafile. Each XML element or attribute applied to the document and locatedby parsing the XML data map is applied to a generalized instancestructure of the selected XML schema file to create ahierarchically-structured instance structure of the XML data applied tothe document. The data for cells or list objects located in the documentby parsing the XML data map are extracted and are arrangedhierarchically according to the generalized instance structure. Thehierarchical arrangement of the XML data and associated user data iswritten to memory or is exported for other subsequent uses.

These and other features and advantages, which characterize the presentinvention, will be apparent from the reading the following detaileddescription and a review of the associated drawings. It is to beunderstood that both the foregoing general description and the followingdetailed description are exemplary and explanatory only and are notrestrictive of the invention as claimed.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a simplified block diagram illustrating the importing ofeXtensible Markup Language data into a spreadsheet document and showingthe exporting of eXtensible Markup Language data from a spreadsheetdocument.

FIG. 2 is a block diagram of a computer and associated peripheral andnetworked devices that provide an exemplary operating environment forthe present invention.

FIG. 3 illustrates a computer screen display of a typical spreadsheetworkspace grid and associated tree view pane showing a generalizedinstance of an eXtensible Markup Language (XML) schema file associatedwith the based spreadsheet document opened to a spreadsheet applicationworkspace grid.

FIG. 4 is a flow chart illustrating a method for importing XML data intoa spreadsheet document.

FIG. 5 is a flow chart illustrating a method for exporting XML data froma spreadsheet document.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT

The following description of embodiments of the present invention ismade with reference to the above-described drawings where in likenumerals refer to like parts or components throughout the severalfigures. The present invention is directed to methods and systems forimporting markup language formatted data into a spreadsheet document andfor exporting the markup language-formatted from a spreadsheet document.

Referring now to FIG. 1, a simplified block diagram illustratingimporting markup language-formatted data into a spreadsheet document andillustrating exporting markup language-formatted data from a spreadsheetdocument is described. According to embodiments of the presentinvention, a preferred markup language for use in accordance with thepresent invention is the eXtensible Markup Language (XML). In oneembodiment, the present invention is incorporated into the OFFICE suiteof application programs that is manufactured and marketed by MICROSOFTCORPORATION of Redmond, Wash. A suitable spreadsheet application for usein accordance with the present invention is the EXCEL spreadsheetapplication manufactured and marketed by MICROSOFT CORPORATION ofRedmond, Wash.

Referring to FIG. 1, an embodiment of the present invention provides aspreadsheet application the ability to natively understand custom markuplanguage data, such as XML data. For example, if an XML data file 100contains quarterly financial results prepared according to an XML schemafile (for example, an XSD file), embodiments of the present inventionallow that XML data to be imported into a spreadsheet document 150 ortemplate with a single import function, such as clicking an importbutton provided by the spreadsheet application 120. Accordingly, theimported data will “land” in the spreadsheet document or template 150 inthe appropriate cells and columns of the spreadsheet grid 160 asspecified by the designer/creator of the template or document. That is,if the user imports an XML document having two elements for “date” and“amount” data associated with company sales, an embodiment of thepresent invention will cause the data from the two elements to importinto a position in the target grid 160 in the same positions asspecified by the map.

As described above, a user may import XML data into a spreadsheet gridand edit that data for subsequent export. Or, a user may start with ablank mapped grid (for example, a grid that has XML data mapped to it,but no other data) and enter data to the blank mapped grid forsubsequent export. However, if a user adds new data, for example, a newcolumn of data to the spreadsheet grid, that data must be mapped to theXML schema file in order for XML data entered for the new column to beincluded in the exported XML data.

FIG. 2 and the following discussion are intended to provide a brief,general description of a suitable computing environment in which theinvention may be implemented. While the invention will be described inthe general context of an application program that runs on an operatingsystem in conjunction with a personal computer, those skilled in the artwill recognize that the invention also may be implemented in combinationwith other program modules. Generally, program modules include routines,programs, components, data structures, etc. that perform particulartasks or implement particular abstract data types. Moreover, thoseskilled in the art will appreciate that the invention may be practicedwith other computer system configurations, including hand-held devices,multiprocessor systems, microprocessor-based or programmable consumerelectronics, cell phones, minicomputers, mainframe computers, and thelike. The invention may also be practiced in distributed computingenvironments where tasks are performed by remote processing devices thatare linked through a communications network. In a distributed computingenvironment, program modules may be located in both local and remotememory storage devices.

With reference to FIG. 2, an exemplary system for implementing theinvention includes a conventional personal computer 20, including aprocessing unit 21, a system memory 22, and a system bus 23 that couplesthe system memory to the processing unit 21. The system memory 22includes read-only memory (ROM) 24 and random access memory (RAM) 25. Abasic input/output system 26 (BIOS), containing the basic routines thathelp to transfer information between elements within the personalcomputer 20, such as during start-up, is stored in ROM 24. The personalcomputer 20 further includes a hard disk drive 27, a magnetic disk drive28, e.g., to read from or write to a removable disk 29, and an opticaldisk drive 30, e.g., for reading a CD-ROM disk 31 or to read from orwrite to other optical media. The hard disk drive 27, magnetic diskdrive 28, and optical disk drive 30 are connected to the system bus 23by a hard disk drive interface 32, a magnetic disk drive interface 33,and an optical drive interface 34, respectively. The drives and theirassociated computer-readable media provide non-volatile storage for thepersonal computer 20. Although the description of computer-readablemedia above refers to a hard disk, a removable magnetic disk and aCD-ROM disk, it should be appreciated by those skilled in the art thatother types of media which are readable by a computer, such as magneticcassettes, flash memory cards, digital video disks, Bernoullicartridges, and the like, may also be used in the exemplary operatingenvironment.

A number of program modules may be stored in the drives and RAM 25,including an operating system 35 and one or more application programs100, such as a spreadsheet application program, a word processorprogram, or other type of program module. Other program modulesillustrated in FIG. 2 include an XML processing module 105, a documentobject model (DOM) parser 37, and a simple application programminginterface for XML (SAX) parser 38. According to an embodiment of theinvention, the XML module 105 is used by the spreadsheet application 100for processing data formatted according to the eXtensible MarkupLanguage. A suitable XML processing module is MSXML manufactured andmarketed by Microsoft Corporation of Redmond, Wash.

A user may enter commands and information into the personal computer 20through a keyboard 40 and pointing device, such as a mouse 42. Otherinput devices (not shown) may include a microphone, joystick, game pad,satellite dish, scanner, or the like. These and other input devices areoften connected to the processing unit 21 through a serial portinterface 46 that is coupled to the system bus, but may be connected byother interfaces, such as a game port or a universal serial bus (USB). Amonitor 47 or other type of display device is also connected to thesystem bus 23 via an interface, such as a video adapter 48. In additionto the monitor, personal computers typically include other peripheraloutput devices (not shown), such as speakers or printers.

The personal computer 20 may operate in a networked environment usinglogical connections to one or more remote computers, such as a remotecomputer 49. The remote computer 49 may be a server, a router, a peerdevice or other common network node, and typically includes many or allof the elements described relative to the personal computer 20, althoughonly a memory storage device 50 has been illustrated in FIG. 2. Thelogical connections depicted in FIG. 2 include a local area network(LAN) 51 and a wide area network (WAN) 52. Such networking environmentsare commonplace in offices, enterprise-wide computer networks, intranetsand the Internet.

When used in a LAN networking environment, the personal computer 20 isconnected to the LAN 51 through a network interface 53. When used in aWAN networking environment, the personal computer 20 typically includesa modem 54 or other means for establishing communications over the WAN52, such as the Internet. The modem 54, which may be internal orexternal, is connected to the system bus 23 via the serial portinterface 46. In a networked environment, program modules depictedrelative to the personal computer 20, or portions thereof, may be storedin the remote memory storage device. It will be appreciated that thenetwork connections shown are exemplary and other means of establishinga communications link between the computers may be used.

In order to provide the document with a set of grammatical and data typerules governing the types and structure of data that may be included ina given document an XML schema is attached to or associated with thedocument for providing the rules governing each of the XML elements andtags with which the user may annotate the given document. For example, a“purchase order” document may have an attached or associated schema suchas “purchaseorder-schema.xsd” for providing the allowable set of XMLelements such as a <date> element, <price> element, <quantity> element,and so on. The schema includes the rules governing the order with whichthose elements may be applied to the document and specific rulesassociated with individual elements applied to the document. Forexample, a schema attached or associated with the “purchase order”document may prescribe that data associated with a given element, forexample a <date> element, must include a day element, followed by amonth element, followed by a year element. Additionally, the schema mayrequire that a <date> element must immediately precede a <shipmentdestination> element, for example.

As is understood by those skilled in the art, developers of XML schemasdetermine the names of XML elements and the associated data types anddata structures allowed for those elements. Then, all users of documentsannotated with XML structure according to a given schema may utilize thedata contained within the XML structure without regard to the overalltype and structure of the document. For example, if a “purchase order”document, described above, is transmitted to a purchaser of the goods,the purchaser may develop software applications for parsing the documentto locate specific types of data within the document for use by thepurchaser. The purchaser may, for example only wish to print serialnumbers and associated prices for certain goods. Using the schemaattached to the document, the purchaser will know that the dataassociated with the XML elements have been prepared according to theschema governing the document. Accordingly, the purchaser may develop asoftware application or an eXtensible Stylesheet Language Transformation(XSLT) file for locating the <price> element and for extracting the dataassociated therewith for insertion into the purchaser's own documents.

Following with this example, a number of different purchasers maysubscribe to the same schema for dictating the rules associated with the“purchase order” document so that each purchaser may then receive the“purchase order” document from the author of the document and use thedata contained in the purchase order according to the XML elementsstructuring the data. That is, a first purchaser may only be interestedin the data contained within the <price> element, while a secondpurchaser may be interested in extracting only the data contained in a<shipment terms> element. Each purchaser may extract the data it desireswithout regard to other aspects or elements of the document by usingtheir own software applications or XSLT transformation files forlocating the desired data according to the XML structure. This is madepossible by the fact that each user of the document follows the datatype and data structure rules prescribed in the schema attached to orassociated with the document.

As understood by those familiar with the eXtensible Markup Language, XMLnamespaces provide a method for qualifying elements and attribute namesused in XML documents by associating those elements and attribute nameswith namespaces identified by uniform resources identifier (URI)references. An XML namespace is a collection of names, identified by aURI reference, which are used in XML documents as element types andattribute names. A single XML document may contain elements andattributes that are defined for and used by multiple software modules.For example, in accordance with an embodiment of the present invention,a single XML document, such as a spreadsheet document, may containelements and attributes defined and used by different software modules.For example, a spreadsheet document may have elements and attributesdefined for and used by a spreadsheet application XML processing module,or the document may contain elements and attributes defined for and usedby or associated with one or more schema files associated with thedocument. For example, elements and attributes may be associated withthe spreadsheet document to associate the document with a schema fileassociated with a purchase order, resume document, a legal document, andthe like. Accordingly, an individual document, such as an exemplaryspreadsheet document may have a namespace identifying the element typesand attribute names associated with each of the different softwaremodules that may consume or use data from the document. A set ofstandard XML data types has been defined by the World Wide Webconsortium (W3C) at http://www.w3c.org/TR/xmlschema-0/simpletypestable,the disclosure of which is incorporated here and by reference.

In order to import an XML data file to a spreadsheet document and inorder to export an XML data file from a spreadsheet document, thespreadsheet application “remembers” the relationships between cells andlist objects in the spreadsheet application grid and correspondingelements or attributes of an associated XML schema file defining thestructure/blueprint of XML data documents corresponding to that schemafile. In order to remember the relationship between the cells and/orlist objects and elements or attributes of the associated XML schemafile, cells and/or list objects are mapped to associated elements orattributes in the schema file. For example, if a cell is supposed toreceive data when an XML data file is imported, that cell is referred toas a “mapped” cell as opposed to an “unmapped” cell that may receivedata entered by a user, but that does not receive data associated withan XML schema file attached to or associated with the imported XML datafile. In order to map a cell or list object with an associated elementor attribute of the XML schema file, markers known as XPATHs are storedin the spreadsheet document to point a given cell or list object to acorresponding element or attribute in an associated XML schema file. Useof and operation of XPATHs are defined by the World Wide Web consortium.

Accordingly, the mapping is a collection of XPATH markers that define arelationship between the spreadsheet application grid and a particularXML schema file where the XPATH is a pointer back to the associatedschema file. For example, if cell B1 has an XPATH marker that points tothe <date> element in an associated XML schema file, the relationshipbetween cell B1 and the <date> element of the associated schema file ismaintained when an XML data file containing the relationship betweencell B1 and the associated schema file is imported to a spreadsheetdocument 150 via a spreadsheet application 120. For example, if theimported XML data file 100 includes a <date> element with value “2 Jan.2003”, and the map in the spreadsheet document specifies that cell B1 ofthe document 150 is related to the <date> element (by an XPATHreferencing the <date> element), then cell B1 will contain “2 Jan. 2003”once the import is finished. For a further description of mapping datain a document to an associated schema file, see U.S. Patent ApplicationPub. No. 2004/0172616, entitled “Markup Language Visual Mapping”, filedon Feb. 28, 2003 and assigned to the same assignee as the presentapplication, which is incorporated herein by reference as if fully setout herein.

FIG. 3 illustrates a computer screen display of a typical spreadsheetapplication workspace and an associated tree view pane showing ageneralized instance of an XML schema file associated with thespreadsheet document. Further, FIG. 3 illustrates a mapping of XMLelements or attributes of the XML schema file to a spreadsheetapplication workspace grid. According to the exemplary screen display300 illustrated in FIG. 3, a spreadsheet application grid (hereafter“grid”) 160 is illustrated for entering, manipulating, and calculatingdata including text and numeric data. On the right hand side of thescreen display 300, a tree view 320 of a generalized instance of an XMLschema file is presented in a task pane 315. The tree view structure 320includes a root element 325, and child elements 330 and 340 and aplurality of child elements 335 and 345 under the elements 330 and 340,respectively. The tree view 320, illustrated in FIG. 3, represents ageneralized instance of an XML schema file attached to or associatedwith the spreadsheet document illustrated in the spreadsheet grid 160.Cells 355, 360, and 365 illustrate single non-repeating elements draggedto the grid 160 from the tree view structure 320. The list objects 370illustrate repeating elements, <description>, <amount> and <date>,dragged from the tree view structure 320 to the grid 160. As illustratedin FIG. 3, data associated with those elements is also illustrated. Thenon-repeating element 355, 360 and 365 are shown structured in cells D3,D4, and D5 of the grid 160. Associated data is entered into each ofthose cells, as shown in FIG. 3. The single non-repeating element <date>and the repeating elements <description> and <amount> are annotated attarget locations D8, E8, and F8 respectively. Associated data is shownas lists under headings associated with of those elements.

According to an embodiment of the present invention, dragging a givenelement or attribute from the tree view 320 to the grid 160 allows theuser to annotate a target location in the grid 160 with markup language(for example, XML) structure associated with the dragged and droppedelement or attribute. For example, referring to FIG. 3, the <date>element 335 is dragged from the tree view structure 320 to a targetlocation Cell D4 in the grid 160. Data associated with that targetlocation, for example “2001-01-01” illustrated in FIG. 3, is shown inthe target spreadsheet Cell D4. Once the selected element or attributeis dragged from the tree view structure 320 and is dropped onto a targetlocation in the spreadsheet grid 160, an XPATH marker is written to thetarget location to point the target location back to the XML schemaelement or attribute to which the target location is now associated.

The mapping of the XML elements or attributes to target locations in thespreadsheet grid, as described above, is advantageous because it allowsthe spreadsheet application to interact with other applications that arenot compatible with or otherwise do not speak the same language of thespreadsheet. If the spreadsheet application imports XML data from afinancial accounting system, for example, the accounting system does nothave to know the data is being consumed by a spreadsheet application onthe other end so long as the spreadsheet application can understand theXML data in question (via an XML data mapping). Likewise, if thespreadsheet application exports data back to that accounting system, theaccounting system does not have to know the data is coming from thespreadsheet application so long as the data conforms to an XML schemathat the accounting system understands. If the consumer wishes toextract the “date” from the spreadsheet grid 310, the consumingapplication may make use of the mapping between the <date> element ofthe marked-up of language schema file to the grid location D4 to readilylocate data associated with the “date” for extracting the data orotherwise utilizing the data. That is, in accordance with embodiments ofthe present invention, the annotation of the spreadsheet grid 160 withmarkup language structure and association of that structure with amarkup language schema file for defining data associated with thestructure is maintained in the grid document for subsequent use andconsumption by other consuming spreadsheet applications or other typesof application capable of consuming and using the markup language datanow associated with the spreadsheet application grid 160.

Importing XML Data to a Spreadsheet Application Document

FIG. 4 is a flow chart illustrating a method for importing XML data intoa spreadsheet document. In order to import an XML data file 100 into aspreadsheet document 150 via the spreadsheet application 120,illustrated in FIG. 1, the method 400 begins at start step 405 andproceeds to step 410 where a data file including XML data is selectedfor importing to a spreadsheet application grid 160 of a spreadsheetdocument 150 via a spreadsheet application 120. As should be understood,the selection of a file may be done via an import function where a useris allowed to import data from a file or to import an entire file intothe grid 160 via of spreadsheet application 120. In the case of animport operation, the user chooses a source that gives XML data to thespreadsheet application grid. The source may be a file containing theXML data, or a stream of bytes containing XML data, or a web-basedservice, or any other application that outputs XML data.

In order to import and utilize XML data of the imported file, the filemust have been associated with an XML schema file, and the XML schemamust have been mapped to the spreadsheet grid. At step 415, thespreadsheet application identifies the XML data mapping that correspondsto the incoming XML data file. The matching XML data map correspondingto the XML data is found by matching the root name and namespace of theXML data with that of the XML schema file associated with all the mapsin the spreadsheet document. If more than one XML data mapping isavailable for the imported document, the user is queried via a userinterface to select one of the multiple available mappings. For example,if the imported XML document contains XML data for quarterly salesfigures, a first XML mapping may have been prepared, as described withreference to FIG. 3, using an XML schema file that defines the XML datawhere only the aggregate sales for each quarter are mapped to thespreadsheet document to give a summary report. A second XML mapping mayhave been created in the same spreadsheet document where a different setof elements and attributes from the XML schema may have been mapped togive a detailed report of the sales data.

At step 420, the XML data mapping is parsed so that each element orattribute mapped to the grid is located. For instance, the first listobject or single mapped cell is found which has a mapping thatcorresponds to the XML map being imported. If a single mapped cell isfound, the XPATH associated with it is obtained. This XPATH is passed toa flattening module that parses the XML data by loading it into adocument object model (DOM) parser that in turn fetches the data thatcorresponds to the XPATH. If a list object is found, all the XPATHsassociated with the columns of the list are collected. The collection ofXPATHs are passed to the flattening module which uses the DOM and theschema associated with the XML data map to determine the layout of theresulting data. The flattening module returns the data in a flat datastructure that can be populated in the spreadsheet document. As is knownto those skilled in the art, DOM parsers are tree-based parsers thatload an entire XML file into memory and SAX parsers are event-basedparsers capable of reading XML nodes (elements and/or attributes)sequentially, one at a time. According to document object models, adocument is presented as a logical structure rather than as a collectionof tagged words. The document object model is a means of defining adocument as a tree-like hierarchy of nodes in which the document is anobject containing other objects, such as images and forms. An example ofa DOM parser is MSXML DOM provided by Microsoft Corporation of Redmond,Wash. For a detailed description of a suitable flattening module, seeU.S. Patent Application Pub. No. 20040172590, entitled “Method andSystem for Converting a Schema-Based Hierarchical Data Structure into aFlat Data Structure,” filed on Feb. 28, 2003 and assigned to the sameassignee of the present application, which is incorporated herein byreference as if fully set out herein.

At step 425, once all XPATHs marked in the imported data file areobtained by the DOM parser, the XPATHs are passed to the XML processingmodule 105 for executing the XPATHs. At step 430, the XML processingmodule 105 executes each XPATH, one by one, against the XML data file tolocate all cells and list object ranges and for finding associated XMLelements or attributes applied to those cells and list object (list)ranges from the associated XML schema file.

At step 435, after each XPATH located in the XML data mapping for theimported document is executed to obtain the cell or list object listrange locations for the XML data and the user data and for relating backto the associated schema file for associated XML schema definitions, alayout for the grid 160 of the spreadsheet worksheet associated with theimported data file is determined by the spreadsheet application 120 inconjunction with the XML processing module 105. At step 440, the cellsand list object list ranges of the grids 160 are populated withassociated XML data.

According to an embodiment of the present invention, when the data ispopulated in the spreadsheet grid 160 for use by the user, the data isconverted from a hierarchical data structure associated with the datamapping into a flattened structure for rendering a presentation in thespreadsheet application grid. For a detailed description of a methodsand systems for converting the hierarchically-structured data into aflattened data structure for presentation to the user in the spreadsheetgrid, see U.S. Patent Application Pub. No. 20040172590, entitled “Methodand System for Converting a Schema-Based Hierarchical Data Structureinto a Flat Data Structure,” filed on Feb. 28, 2003 and assigned to thesame assignee of the present application, which is incorporated hereinby reference as if fully set out herein. As should be understood, afterthe data obtained from the flattening module is properly formatted andpopulated into the spreadsheet cells or lists, the process continuesagain until all data for all the cells and lists associated to the XMLmapping are imported into the spreadsheet grid. The method ends at step495.

Exporting XML Data from a Spreadsheet Application Worksheet

Referring to FIG. 5, after a user has imported XML data to thespreadsheet application grid 160 for editing, as described withreference to FIG. 4, or after the user has created a new XML documentand mapped an associated schema file to that document, the user mayexport the XML document along with XML markup, XML data, and XML datamapping for subsequent use. According to embodiments of the presentinvention, the user may also export an XML document where XML structureis associated (via a schema (XSD)) to a spreadsheet having pre-existingdata. Advantageously, upon export, all relationships created betweencell and list object locations in the spreadsheet application grid 160and the associated schema file are maintained for subsequent use by anyother XML-enabled application. Referring to FIG. 5, a method forexporting XML data from a spreadsheet document according to anembodiment of the present invention is described. The method 500 beginsat start step 505 and proceeds to step 510 where an XML data file isselected for exporting. As briefly described above, the XML data filemay be a data file previously imported, as described with reference toFIG. 4, or the data file may be a new file created by the user who nowdesires to export the data file. According to an embodiment of theinvention, the user may be prompted for a name of a file that will becreated and to which the XML document will be written. If the named filealready exists, the user may be prompted as to whether to overwrite thefile or to choose a different file name.

At step 515, an XML data mapping defining the relationship between XMLdata in the document to be exported and an associated schema file isselected. The XML data mapping selected for the export of the data maybe the mapping used for importing the data, as described above withreference to FIG. 4. Alternatively, if the data file to be exported isbeing created by the user, an XML data mapping between the document grid160 and an associated schema file may be created, as described abovewith reference to FIG. 3. At step 520, a determination is made as towhether more than one XML data mapping is present. If there is more thanone, the user is prompted to specify which mapping to export. Asdescribed above with reference to FIG. 4, the document previouslyimported by the user, or being created by the user may have more thanone mapping associated with an XML schema file. If more than one XMLdata mapping is present, the method proceeds to step 520, and the useris queried via a user interface for a selection of one of multiple datamappings. Once a mapping is selected, the method proceeds to step 530,and the XML data mapping is obtained for use in preparing the data forexporting.

At step 535, the XML data mapping is matched to a generalized instancestructure created for the associated schema file, as described abovewith reference to FIG. 3. As described above, the generalized instancestructure is a tree-like hierarchical representation of an XMLhierarchical data structure where all available elements and/orattributes of an associated schema file are applied to the document.That is, the instance structure represents a potential hierarchical datastructure of a document having all potential elements and/or attributesof an associated schema file applied to the document. At step 535, theselected XML data mapping is matched to a corresponding generalizedinstance structure. For example, if the XML data mapping was prepared inassociation with a purchase order schema file at step 535, that XML datamapping is matched to a corresponding generalized instance structureprepared for the purchase order schema file.

At step 540, the XML data mapping's generalized instance structure ispassed to the XML processing module 105. The XML export module iteratesthe grid's data to extract references to the data associated to themapping specified by the user. The references are stored in thegeneralized instance structure. According to an embodiment of thepresent invention, the XML processing module walks through the XML datamapping node by node for the document to be exported to find thelocation of and content of XML data applied to the document.Advantageously, iteration of the map to find data associated with thespreadsheet document allows the XML export module to associate datacontained in the spreadsheet document with corresponding XML structurein the generalized instance structure so that the location andhierarchical order of the data may be determined for the eventual exportof the data for subsequent use.

At step 545, the XML processing module 105 locates each element and/orattribute applied from the associated schema file to the spreadsheetdocument via the mapping between the generalized instance structure ofthe XML schema file to the spreadsheet document. For each reference inthe XML data mapping located by the XML export module, the XML exportmodule obtains an XPATH marking the location of the XML data in thedocument and pointing that location and data back to the XML schemafile. For example, if the XML export module comes to a first referencein the XML data mapping that is representative of a <first name> XMLdata element, the XML processing module 105 obtains the associatedXPATH, for example, “//purchaseorder/person/fname” for pointing to the<first name> child element of the element <person> which in turn is achild element of the element <purchaseorder> of an associated purchaseorder schema file applied to the document. In effect, each cell or listobject annotated with XML data according to the associated XML schemafile is located by walking a list of XML data mappings. The associatedXPATH locating a cell or list object and data associated therewith isused to apply the XML data to the generalized instance structure of theassociated XML schema file to prepare a hierarchically-structuredrepresentation of the XML data and associated user data contained in thedocument. At step 550, each XPATH obtained by the XML export module andassociated with a given XML data element or attribute applied to thedocument is used to associate each applied element or attribute to thegeneralized instance structure associated with the selected XML schemafile. In effect, the generalized instance structure is “filled in” toindicate which elements and/or attributes of the generalized instancestructure of the selected XML schema file are actually applied to thedocument.

If the location of a single non-repeating element or attribute is found,the associated XPATH for the location and the associated data will bepushed out to the generalized instance structure, as described above.However, if during iteration of the map at step 540, a list object isfound having a cell range, for example cell C5 through cell C15, anindication is made that the list object is associated with a repeatingelement in generalized instance structure of the associated XML schemafile. In response, the XML export module analyzes the hierarchicalstructure of the generalized instance structure to find the XML elementassociated with the list found in the application document anddetermines the minimum number of repeats associated with the element.This is required in order to ultimately know where the associated datais located in the document so that the data may be pushed out to thegeneralized instance structure for creating a hierarchically-structuredrepresentation of the XML document for export.

At step 555, the mapped data associated with each XPATH in the documentis extracted, and at step 560 the extracted data is arranged by the XMLexport module 37 according to the generalized instance structure. Inorder to arrange the extracted data in a hierarchical structure, the XMLprocessing module 105 walks down the generalized instance structure onenode at a time to prepare the data for writing to memory and forvalidating the data against the XML schema file. For example, if the DOMparser and SAX module locates a first element corresponding to a singlenon-repeating <name> element, the data, if any, contained in the cellassociated with that element is validated against the <name> element ofthe associated schema file. That is, if the <name> element requires afirst name, followed by a middle name, followed by a last name, the DOMparser and SAX module determine if the associated data is validaccording to that data type and structure. If the data is not valid, aschema validation error may be presented to the user.

If the XML processing module locates a list object that repeats, forexample ten times, according to the generalized instance structure ofthe XML schema file, then associated data of the ten cells are arrangedfor the eventual export. With each cell in the column that is arranged,data associated therewith is validated against the XML schema file,described above. According to a preferred embodiment of the presentinvention, the rendering of the data according to the associated schemafile is honored unless the rendering dictated by the schema file willcause a loss of user entered data. For example, if the associated schemafile requires that an annotated cell contain a whole number, but theuser-entered a decimal value (for example, whole number 8 versus decimalnumber 8.5), the decimal value will be written out to memory, and theuser will be provided with an XML schema validation error.

At step 565, the XML export module via the SAX module writes out thehierarchically-structured data to memory for subsequent import and useas described above with reference to FIG. 4. As should be understood avariety of options are available when the data is written out to memoryat step 565. The data may be written to memory for future import asdescribed with reference to FIG. 4, or the data may be transformed usinga transformation file such as an eXtensible Stylesheet LanguageTransformation (XSLT) file to transform the data into a different formatfor subsequent consumption, for example, consumption by a HypertextMarkup Language processing module. Alternatively, at step 565 the datamay be sent to another user for import by the second user utilizinganother spreadsheet application program 120, or alternatively, forimport by a different software application, such as a word-processingapplication. If the document is sent to another user for import by thesecond user utilizing a separate software application program, such as aword processing application, the spreadsheet functionality associatedwith the document created by the first user may be lost, butadvantageously, the XML formatting of the data including XML tags andapplication of elements and/or attributes from the associated schemafile are maintained in the data for use by the second user.

Additionally, during the process of writing out the data to memory atstep 565, a determination may be made based on the associated schemafile as to whether or not a given element is optional. That is,according to one embodiment, a determination may be made as to whetheran element applied to the document that should be rendered according tothe associated schema file may nonetheless be omitted where, forexample, rendering the element will generate a blank cell. For examplesometimes an element is expressed that is not optional, but the elementdoes not have data in the document location to which it is applied, forexample, a NIL value. If a cell has an Integer data type according tothe associated schema file, but the cell does not have an expressedvalue, a zero(0) cannot be expressed in the cell because a zero is avalid Integer data type that in all probability does not convey theintent of a cell with no data content. For another example, say a<price> element is optional, and twenty <price> elements must be parsedaccording to the general instance structure of the associated schemafile. If the schema file dictates that the <price> element is required,each time a <price> element is parsed having no associated price items(user data) an empty element is written. An empty element is shorthandfor having an open tag and a closed tag with nothing in between.

As is known to those skilled in the art, in the described example caseXML syntax may be written to prevent an empty cell from filling in withzeros. For example, when a cell has no data content, XML syntax may bewritten to prevent that empty cell from filling in with zeros. Asdescribed above, one example is an empty element that is required andanother example is where a number data type such as an Integer data typeis required and the user does not enter data to the cell. In either ofthese cases, writing a blank as a description would not be valid againstthe associated schema file, and a schema validation error would occurand likely confuse a user. According to one embodiment, if the XSDdefines the element to be “nillable” a NIL value is written to the cellby writing an attribute of “xsi:nil=‘true’” where the namespace prefix“xsi” is associated to the http://www.w3c.org/2001/XMLSchema-instancenamespace in that location so that the schema validation process willignore the cell. On export, the element may be tagged stating that thecell should be expressed as a NIL value that will prevent a validationerror from being provided to the user. If an element is required, butwhere no data is provided, according to one embodiment, the element maybe written out to memory at step 565 to adhere to the associated schemafile, and an empty element may be written out even though it is invalidversus the schema file, but where it is the best interpretation of theuser's desires. A schema validation error may then be presented to theuser to alert the user.

Contextual Awareness

According to embodiments of the present invention, mapping XML data tothe spreadsheet grid, as described herein, may also expose applicationprogramming interfaces (API) that allow a programmer to “peer into” theXML map and use it for other purposes. According to a first aspect ofthis embodiment, if a programmer is working with a specific XML schemasuch as a purchase order (PO) schema, she may want to write a customprogram that provides the user with actions such as “Check status ofthis purchase order” wherever purchase order data is encountered, andthe programmer may want those actions to show up “inline” in thespreadsheet document. Because the XML mapping feature, described above,allows the PO schema to be used in different spreadsheet documents (eachproviding a different “view” of the XML purchase order data), theprogrammer cannot write a program that works in all places. For example,the “Check status” action needs to have access to the <id> element ofthe PO data in order to know which purchase order it should look up forthe user. The programmer therefore needs a way to “discover” whether the<id> element is present at all in the spreadsheet document. Once it hasbeen determined that the <id> element is present, the program code needsto know where the <id> element is mapped in the grid. Once the programcode knows where the <id> element is mapped, the program code is able tofetch the value of the spreadsheet cell to which the <id> element ismapped, as described above. The program code may also use this locationto draw the appropriate user interface (button, etc.) in the vicinity ofthat spreadsheet cell.

The objects are declared that will hold the location and value resultsto be obtained as described above. The element XPATH of the elementneeded by the programmer is passed to an XmlMapQuery method to find thelocation of the element. In response, a Range object is returned whichrepresents some area in the spreadsheet application spreadsheet. If thedesired element does not exist, meaning it has not been mapped into thisparticular spreadsheet, the Range returned will be ‘empty’ orun-initialized. In response, the programmer/user checks for an “empty”Range before continuing. If the Range is not empty, a call is made(e.g., XmlDataQuery) to fetch the Range that contains the actual datafor the Range. XmlMapQuery and XmlDataQuery in many cases return theexact same Range. However, element mappings may contain extrainformation, such as headers, which would be returned by XmlMapQuery,whereas XmlDataQuery returns just the data.

In addition, sometimes a mapping for a particular element may exist, butno data may exist in the mapping yet, in which case XmlDataQuery wouldreturn an “empty” Range, while XmlMapQuery would return valid Range. Insuch cases, the programmer/user may first query for the existence of themapping using XmlMapQuery before accessing the value of that mappingwith XmlDataQuery. Next, a determination is made as to whether themapping (Range) contains any data. The location of the data in thespreadsheet can be obtained from the Range. Accessing the value of theelement is also done with this Range. The Range may contain more thanone cell, but for the purposes of the example, only the first cellhaving a Range “IdRange” is accessed.

According to a second aspect of this embodiment, if the programmer/usermay desire to write a program that is able to work with multipledifferent XML schemas. For example, consider an automobile company thatproduces cars, trucks, and buses where there is an XML schema for eachtype of vehicle that describes all of the parts that go into that typeof vehicle. The company may also have a general-purpose spreadsheettemplate for ordering parts. Users must customize that template bymapping the appropriate elements from one of the three schemas to the“Order Table” section of the spreadsheet. Once they have created themapping, they can fill out the Order Table.

Continuing with the example, the programmer may want to provide theusers with actions that help them fill out the order table, for example,an action like “Get quote.” The programmer already knows where the OrderTable is in the spreadsheet, but does not know which schema (cars,trucks, buses) the user will have mapped in each case, nor the elementsthat the user mapped from the particular schema. The programmer firstdeclares the objects that will hold the results to be obtained below.Next the programmer addresses a Range in the spreadsheet correspondingto one of the columns in the “Order Table”. For example, the programmerlooks up the “Part Number” column in the table, and retrieves the XMLXPATH information from that Range. The programmer then checks to makesure that the column is indeed mapped before proceeding. The XPATHobject provides useful information to the programmer. For example, theXPATH may give the programmer the XPATH identifier of the element thatis mapped to this column. According to the present example, theprogrammer may be interested in identifying the schema that is mapped tothis table, so that she knows how to appropriately request a pricequote. She does this by accessing the XmlMap object (via XPath.Map)associated with XPATH object, followed by retrieving the namespace valuefrom RootElementNamespace that uniquely identifies the schema beingused. After the programmer knows which schema is in use in this table,she performs the action that is appropriate to the given schema, such asinserting a code to get a quote for car parts.

As described herein, embodiments of the present invention relate toimporting markup language data to and exporting markup language datafrom a spreadsheet application grid. It will be apparent to thoseskilled in the art that various modifications or variations may be madein the present invention without departing from the scope or sprit ofthe invention. Other embodiments of the invention will be apparent tothose skilled in the art from consideration of this specification andpractice of the invention disclosed herein.

1. A method of importing eXtensible Markup Language (XML) data into a spreadsheet document and for exporting XML data from a spreadsheet document, comprising: selecting a data file containing XML data for importing into a spreadsheet document; rendering the XML data in the spreadsheet document according to a previously defined mapping of selected XML data to selected target locations in the document; modifying the XML data rendered in the spreadsheet document; updating the mapping to include modifications to the XML data; exporting the modified XML data and updated mapping for subsequent rendering in a second spreadsheet document according to the updated mapping.
 2. The method of claim 1, whereby the step of modifying the XML data rendered in the spreadsheet document includes modifying XML data applied to the document and modifying user data entered into the document, and whereby the step of exporting the modified XML data and updated mapping includes exporting modified user data entered into the document.
 3. A computer readable medium having computer executable instructions contained thereon which when executed by a computer perform the following steps for importing eXtensible Markup Language (XML) data into a spreadsheet document and for exporting XML data from a spreadsheet document, comprising: selecting a data file containing XML data for importing into a spreadsheet document; rendering the XML data in the spreadsheet document according to a previously defined mapping of selected XML data to selected target locations in the document; modifying the XML data rendered in the spreadsheet document; updating the mapping to include modifications to the XML data; exporting the modified XML data and updated mapping for subsequent rendering in a second spreadsheet document according to the updated mapping. 